<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>对象拷贝</title>
</head>
<body>
<script>
    let arr = [
        {name: 'Samuel', age: 24},
        {name: 'ZhuangBifan', age: 24}
    ]

    function deepCopy(obj) {
        return JSON.parse(JSON.stringify(obj));
    }

    let result = deepCopy(arr);
    result[1].name = 'ZhangFan';
    console.log(arr);
    console.log(result);
</script>
</body>
</html>
